<template>

  <div class="mianContent clearfix">

    <div class="part_one clearfix">
      <div class="item_left">
        <div class="title clearfix">
          <p class="fl"><img :src="src1" alt="" />{{name1}}</p>
          <p class="fr" @click="newsMore(id1)" v-bind:id="id1">更多<img src="/assets/image/home_modu_icon_add@2x.png" alt="" /></p>
        </div>

        <div class="swiper_left">
          <el-carousel>
            <el-carousel-item :key="index" v-for="(item,index) in liveList.slice(0, 3)" @click.native="liveDetails(item)">
              <div class="swiperContent">
                <img :src="item.fakuImg" alt="">
                <p class="text-1">{{item.title}}</p>
              </div>
            </el-carousel-item>
          </el-carousel>

        </div>

        <div class="live_item">
          <ul class="newItem liveItem">
            <li @click="liveDetails(item)" v-for="(item,index) in liveList.slice(3,9)" :key="index">

              <p class="content text-1"> <i class="circle"></i> {{item.title}}</p>
            </li>

          </ul>
        </div>

      </div>
      <div class="item_right">
        <div class="title clearfix">
          <p class="fl"><img :src="src2" alt="" />{{name2}}</p>
          <p class="fr" @click="opinionMore(id2)" :id="id2">更多<img src="/assets/image/home_modu_icon_add@2x.png" alt=""></p>
        </div>
        <div class="timelines">
          <el-timeline>
            <el-timeline-item v-for="item in lawList.slice(0, 4)" :key="item.id" :timestamp="item.createTime" @click.native="lawDetails(item)">
              <p class="content"> {{item.title}}</p>
            </el-timeline-item>
          </el-timeline>
        </div>
      </div>
    </div>

    <div class="part_two clearfix">
      <div class="item_left">
        <div class="title clearfix">
          <p class="fl"><img :src="src6" alt="" />{{name6}}</p>
          <p class="fr" @click="classMore(id6)" :id="id6">更多<img src="/assets/image/home_modu_icon_add@2x.png" alt=""></p>
        </div>
        <div class="imgItem">
          <div v-for="item in couseList" :key="item.id" @click="classDetails(item)">
            <img :src="item.courseImg" alt="">
            <p>{{item.courseName}}</p>
          </div>
        </div>

      </div>
      <div class="item_right">
        <div class="title clearfix" style="margin-bottom:0.1rem;">
          <p class="fl"><img src="/assets/image/home_modu_icon_4@2x.png" alt="">更多精彩</p>
        </div>

        <!-- <div class="iconItem clearfix">
          <div @click="jiqiren()"><img src="../assets/image/home_more_icon_1@2x.png" alt=""></div>
          <div @click="laws(7)"><img src="../assets/image/home_more_icon_22@2x.png" alt=""></div>
          <div @click="regulations(id3)" :id="id3"><img :src="src3"></div>
          <div @click="games()"><img src="../assets/image/home_more_icon_4@2x.png" alt=""></div>
        </div> -->

        <div class="iconItems clearfix">
          <div class="item1">
            <img @click="jiqiren()" src="/assets/image/home_more_icon_1.png" alt="">
            <img @click="laws(7)" src="/assets/image/home_more_icon_2.png" alt="">
          </div>
          <div class="item2">
            <img @click="regulations(id3)" :src="src3" alt="">
            <img @click="games()" src="/assets/image/home_more_icon_4@2x.png" alt="">
            <img @click="toExam()" src="/assets/image/home_more_icon_5@2x.png" alt="">
          </div>
        </div>

      </div>
    </div>

  </div>

</template>
<script>
import path from '@/network'
import API from '@/api.js'
export default {
  name: 'App',
  data () {
    return {
      name1: '',
      name2: '',
      name3: '',
      name4: '',
      name5: '',
      name6: '',
      name7: '法律法规',
      src1: '',
      src2: '',
      src3: '',
      src4: '',
      src5: '',
      src6: '',
      id1: '',
      id2: '',
      id3: '',
      id4: '',
      id5: '',
      id6: '',
      total: 0,
      pagesize: 10,
      currentPage: 1,
      couseList: [],
      imgList: [],
      liveList: [],
      lawList: [],
    }
  },
  created () {
    this.basepath = this.$root.basepath
  },
  mounted () {
    this.getIndexType(1);
    this.getIndexType(2);
    this.getIndexType(3);
    this.getIndexType(4);
    this.getIndexType(5);
    this.getIndexType(6);
    this.getLiveList(0);
    this.getLawList(3);
    this.getCourseList()
    // alert(document.body.clientHeight)
    // alert(document.body.clientWidth)
  },
  methods: {
    toExam: function () {
      this.$router.push({ name: 'examList', query: { title: this.name } })
    },
    newsMore: function (id) {
      this.$router.push({ name: 'news', query: { firstId: id, title: this.name1 } })
    },
    classMore: function (id) {
      this.$router.push({ name: 'lawClass', query: { id: id, title: this.name6 } })

    },
    regulations: function (id) {
      this.$router.push({ name: 'regulations', query: { firstId: id, title: this.name3 } })
    },
    laws: function (id) {
      //this.$router.push({ name: 'laws', query: { firstId: id, title: this.name7 } })
      window.location.href = 'https://jiqiren.pluslegal.cn/allro/link?type=5'
    },
    jiqiren: function () {
      window.location.href = 'https://jiqiren.pluslegal.cn/faku/jiqiren_index?type=1&device_id=faku20210909'
      //window.location.href = 'http://localhost:10100/faku/jiqiren_index?type=1&device_id=faku20210909'
    },
    games: function () {
      window.location.href = 'https://jiqiren.pluslegal.cn/faku/games/index?type=1&device_id=faku20210909'
      //window.location.href = 'http://localhost:10100/faku/games/index?type=1&device_id=faku20210909'
    },
    opinionMore: function (id) {
      this.$router.push({ name: 'opinionNews', query: { firstId: id, title: this.name2 } })
    },
    classDetails: function (item) {
      this.$router.push({ name: 'classDetails', query: { id: item.id, name: item.courseName, title: this.name6 } })
    },
    liveDetails: function (item) {
      this.$router.push({ name: 'newsDetails', query: { secondId: item.id, firstId: this.id1, type: 1, title: this.name1 } })
    },
    lawDetails: function (item) {
      this.$router.push({ name: 'opinionNewsDetails', query: { secondId: item.id, firstId: this.id2, title: this.name2 } })
    },

    //获取list
    jiqirenEnter () {
      path.jiqirenEnter().then(res => {
        if (res.success === 0) {
          console.log(res)
        }
      })
    },

    //获取list
    gameEnter () {
      path.gameEnter().then(res => {
        if (res.success === 0) {
          console.log(res)
        }
      })
    },

    //获取type
    getIndexType (id) {
      path.getIndexType(
        id
      ).then(res => {
        if (res.success === 0) {
          if (id == 1) {
            this.name1 = res.rows.name;
            this.src1 = res.rows.img;
            this.id1 = res.rows.id;
          } else if (id == 2) {
            this.name2 = res.rows.name;
            this.src2 = res.rows.img;
            this.id2 = res.rows.id;
          } else if (id == 3) {
            this.name3 = res.rows.name;
            this.src3 = res.rows.img;
            this.id3 = res.rows.id;
          }
          else if (id == 4) {
            this.name4 = res.rows.name;
            this.src4 = res.rows.img;
            this.id4 = res.rows.id;
          }
          else if (id == 5) {
            this.name5 = res.rows.name;
            this.src5 = res.rows.img;
            this.id5 = res.rows.id;
          }
          else if (id == 6) {
            this.name6 = res.rows.name;
            this.src6 = res.rows.img;
            this.id6 = res.rows.id;
          }

        }
      })
    },



    //获取list
    getLiveList (id) {
      path.getLiveList(
        this.currentPage,
        this.pagesize,
        id
      ).then(res => {
        if (res.success === 0) {
          this.liveList = res.rows
        }

      })
    },


    //获取list
    getLawList (id) {
      path.getLawList(
        this.currentPage,
        this.pagesize,
        id
      ).then(res => {
        if (res.success === 0) {
          this.lawList = res.rows;
        }

      })
    },


    //获取list
    getCourseList () {
      path.getCourseList(
        this.currentPage,
        2
      ).then(res => {
        if (res.success === 0) {
          this.couseList = res.rows
        }

      })
    },

  }
}
</script>